const path = require('path');
const webpack = require('webpack');
const ExtractTextPlugin = require("extract-text-webpack-plugin");

module.exports = {
    entry: './src/index.js',
    output: {
        path: path.join(__dirname, "assets"),
        filename: 'bundle.js'
    },
    module: {
        rules: [
            {
                test: /\.js$/,
                enforce: "post",
                use: ['es3ify-loader']
            }, {
                test: /\.css$/,
                use: ExtractTextPlugin.extract({fallback: "style-loader", use: "css-loader"})
            }, {
                test: /\.less$/,
                use: ["style-loader", "css-loader", "less-loader"]
            }
        ]
    },
    plugins: [
        new webpack.BannerPlugin('这个插件用来写几个字'),
        // ExtractTextPlugin，抽取CSS代码
        new ExtractTextPlugin("bundle.css"),
        // CommonsChunkPlugin，抽取JS公共代码
        new webpack.optimize.CommonsChunkPlugin({name: "commons", filename: "commons.js"}),
        // UglifyJsPlugin，压缩JS代码
        new webpack.optimize.UglifyJsPlugin()
    ]
}
